package org.zjt.demo.config;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.zjt.demo.common.ProtectorFilter;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by zhang on 2017/3/13.
 *
 * XSS、SQL、CSRF、File安全
 *
 */
@Configuration
public class SecurityConfig {

    @Bean
    public FilterRegistrationBean getDemoFilter(){
        FilterRegistrationBean registrationBean=new FilterRegistrationBean();
        Map data=new HashMap(1);
        data.put("1","zhangsan");
        registrationBean.setInitParameters(data);
        registrationBean.setFilter(new ProtectorFilter());
        List<String> xxsUrlPatterns=new ArrayList<String>();
        xxsUrlPatterns.add("/*");//拦截路径，可以添加多个
        registrationBean.setUrlPatterns(xxsUrlPatterns);
        registrationBean.setOrder(1);
        return registrationBean;
    }
}
